package com.zd.core.security.service;

import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.zd.core.security.entity.UserDetailsNative;

//http://www.family168.com/tutorial/springsecurity3/html/technical-overview.html
//http://www.family168.com/oa/springsecurity/html/ch208-extenduser.html
//http://77857.blog.51cto.com/67857/177471
//http://spring-rolls.googlecode.com/svn
public class UserDetailsFromDbServiceImpl implements UserDetailsService {
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		System.out.println(username);
		UserDetailsNative userDetails = new UserDetailsNative();
		if(username.equals("zd")) {
			userDetails.setUsername("zd");
			userDetails.setPassword("zd");
		}
		else if(username.equals("bo")) {
			userDetails.setUsername("bo");
			userDetails.setPassword("bo");
		}
		else if(username.equals("test")) {
			userDetails.setUsername("test");
			userDetails.setPassword("test");
		}
		return userDetails;
	}
}
